<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.0.min.js"></script>
    <script src="../../js/ajax.js"></script>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/addPage.css">

</head>

<body>
    <form action="" class="layui-form layui-form-pane">
        
    
        <div class="layui-form-item">
            <label class="layui-form-label">客户编号</label>
            <div class="layui-input-block">
                <input type="text" name="customId"  id="customId" required lay-verify="required"
                    placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-block">
                <input type="text" name="customName"  id="customName" required lay-verify="required"
                    placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="mobile"  id="mobile" required lay-verify="required"
                    placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
       
        <input type="hidden" id="id" name="id">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="send" lay-submit lay-filter="add">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="../../js/host.js"></script>
    <script>
        
        // function count() {
        //     let price = $("#price").val()
        //     let number = $("#number").val()
        //     if (price != "" && number != "") {
        //         if (!isNaN(price)) {
        //             $("#totalPrice").val(parseFloat(price) * number)
        //         } else {
        //             $("#price").val("")
        //         }
        //     }
        // }


        $.ajaxSetup({
                headers: {
                    "token": localStorage.getItem("token")
                }
            });


        $(function () {
            layui.use(["table", "form"], function () {
                var table = layui.table;
                var form = layui.form;
                setTimeout(function () {
                    form.render("select")
                }, 50)
                // $.ajaxSettings.async = false;
                // new ajax(host+"/getCustom", "get", {}, "json", function (data) {
                //     $.each(data, function (index, item) {
                //         $("#customId").append("<option value='" + item.id + "'>" + item.customName + "</option>")
                //     })
                // });
                // new ajax("/getStaff", "get", {}, "json", function (data) {
                //     $.each(data, function (index, item) {
                //         $("#operatorId").append("<option value='" + item.id + "'>" + item.staffName + "</option>")
                //     })
                // });

                form.on("submit(add)", function (data) {
                    new ajax(host+"/addCustom", "get", data.field, "json", function (data) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.layer.msg('提交成功', {
                            icon: 1,
                            time: 2000
                        });
                    });
                    $.ajaxSettings.async = true;
                    return false;
                })

            })
        })
    </script>
</body>

</html>